﻿
namespace EASEater
{
    class Like
    {
        public Like(string key)
        {
            Key = key;
        }

        private string _key;
        public string Key
        {
            get
            {
                return _key;
            }
            set
            {
                _key = string.IsNullOrWhiteSpace(value) ? string.Empty : value.ToLower();
            }
        }

        public Models.Map Parent { get; set; }

        internal bool Search(Models.Map obj)
        {
            return 
                (string.IsNullOrWhiteSpace(Key) || (obj.BillName.ToLower().Contains(Key) || obj.DbName.ToLower().Contains(Key))
                ) && (Parent == null || obj.Parent == Parent.DbName);
        }
    }
}
